package com.suixinsanren.design.compound.demo01;

import java.util.ArrayList;
import java.util.List;

public class Flock implements QuackAble {

    private List<QuackAble> quackAbleList = new ArrayList<>();

    public void add(QuackAble quackAble) {
        quackAbleList.add(quackAble);
    }

    @Override
    public void quack() {
        quackAbleList.iterator().forEachRemaining(QuackAble::quack);
    }

    @Override
    public void registerObserver(Observer observer) {
        quackAbleList.forEach(quackAble -> quackAble.registerObserver(observer));
    }

    @Override
    public void notifyObservers() {

    }
}
